#e
#Title[zNuzÖpv]
#Text[܂euB񎟌iƂjOiv[[jɌĂ̍UB]
#ScriptVersion[2]

script_enemy_main
{
	let scroll=0;
	let flag=0;
	let cx=GetCenterX();
	let cy=GetCenterY();
	let boss=GetCurrentScriptDirectory~"img\boss7-2.png";
	let eye=GetCurrentScriptDirectory~"img\bg7-1.png";
	let asa=GetCurrentScriptDirectory~"img\bg7-2.png";
	LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");
	@Initialize
	{
		SetScore(30000);
		SetLife(800);
		SetDamageRate(10,0);
		SetMovePosition02(cx,cy-120,60);
		SetTimer(80);
		SetInvincibility(60);
		LoadGraphic(boss);
		LoadGraphic(eye);
		LoadGraphic(asa);
		LoadGraphic(GetCurrentScriptDirectory~".\img\shot\bullet.png");
		shottask;
		drawtask;
		bombtask;
		CutIn(YOUMU,"zNuzÖpv",0,0,0,0,0);
	}
	@MainLoop
	{
		yield;
	}
	@Finalize
	{
		loop(16)
		{
			CreateItem(ITEM_SCORE,GetX+rand(-30,30),GetY+rand(-30,30));
		}
		DeleteGraphic(boss);
		DeleteGraphic(eye);
		DeleteGraphic(asa);
		DeleteGraphic(GetCurrentScriptDirectory~".\img\shot\bullet.png");
	}
	@DrawLoop
	{
		SetTexture(boss);	
		if(flag==1)
		{
			SetGraphicRect(52,0,81,63);
		}
		else if(flag==2)
		{
			SetGraphicRect(24,0,52,63);
		}
		else
		{
			SetGraphicRect(0,0,24,63);
		}
		SetGraphicScale(1,1);
		SetGraphicAngle(0,0,0);
		DrawGraphic(GetX,GetY);
	}
	@BackGround
	{
		SetColor(128,128,128);
		SetTexture(eye);	
		SetGraphicRect(0,0,384,448);
		SetAlpha(255);
		SetGraphicScale(1,1);
		SetGraphicAngle(0,0,0);
		DrawGraphic(cx,cy);
		SetColor(255,255,255);
		SetTexture(asa);	
		SetGraphicRect(0,0,888,189*5);
		SetAlpha(64);
		SetGraphicScale(0.5,0.75);
		SetGraphicAngle(0,0,0);
		DrawGraphic(cx+scroll,cy);
		DrawGraphic(cx+scroll-444,cy);
		if(scroll>444)
		{
			scroll=0;
		}
	}
	task shottask
	{
		let angle=0;
		let angle2=0;
		wait(120);
		loop
		{
			loop(12)
			{
				SetShotColor(255,0,32);
				CreateObjLaser(GetX,GetY,angle2,512,16,254,-3,0);
				SetShotColor(255,255,255);
				angle2+=30;
			}
			loop(90)
			{
				CreateShotFromScript("ZoomIn",GetX,GetY,1,angle,30,0);
				CreateShotFromScript("ZoomIn",GetX,GetY,1,-angle/3,30,1);
				angle+=37;
			wait(3);
			}
			loop(12)
			{
				SetShotColor(255,0,32);
				CreateObjLaser(GetX,GetY,angle2,512,16,254,3,0);
				SetShotColor(255,255,255);
				angle2+=30;
			}
			loop(90)
			{
				CreateShotFromScript("ZoomIn",GetX,GetY,1,angle,30,0);
				CreateShotFromScript("ZoomIn",GetX,GetY,1,-angle/3,30,1);
				angle+=37;
			wait(3);
			}
		}
	}
	task drawtask
	{
		let x=0;
		loop
		{	
			if(GetX>x+0.5)
			{
				flag=1;
			}
			else if(GetX<x-0.5)
			{
				flag=2;
			}
			else
			{
				flag=0;
			}
			x=GetX;
			scroll++;
			yield;
		}
	}
	task bombtask
	{
		loop
		{
			if(OnBomb)
			{
				SetAlpha(64);
				SetDamageRate(0,0);
			}
			else
			{
				SetAlpha(255);
				SetDamageRate(20,0);
				SetCollisionA(GetX(),GetY(),24);
				SetCollisionB(GetX(),GetY(),24);
			}
			yield;
		}
	}
	task CreateObjLaser(let x, let y, let angle, let length,let width, let graphic, let angle2, let r)
	{
		let count=0;
		let obj = Obj_Create(OBJ_LASER);
		Obj_SetPosition(obj, x, y);
		Obj_SetSpeed(obj, 0);
		Obj_SetAngle(obj, angle);
		ObjShot_SetGraphic(obj, graphic);
		ObjShot_SetDelay(obj, 90);
		ObjLaser_SetLength(obj, length);
		ObjLaser_SetWidth(obj, width);
		Obj_SetAutoDelete(obj,false);
		while(!Obj_BeDeleted(obj))
		{
			if(count==136)
			{
				Obj_Delete(obj);
			}
			if(count>=120)
			{
				width--;
				Obj_SetCollisionToPlayer(obj,false);
			}
			if(count<60)
			{
				angle+=angle2;
				ObjLaser_SetLength(obj, length*(count/60));
				r+=1.5;
			}
			Obj_SetPosition(obj,GetX+r*cos(angle), GetY+r*sin(angle));
			Obj_SetAngle(obj, angle+30*angle2);
			ObjLaser_SetWidth(obj, width);
			count++;
			yield;
		}
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}

script_shot ZoomIn
{
	let angle=0;
	let scale=0;
	@Initialize
	{
	}
	@MainLoop
	{
		if(GetArgument==0)
		{
			SetCollisionB(GetX,GetY,16*scale);
		}
		if(GetArgument==1)
		{
			SetCollisionB(GetX,GetY,4*scale);
		}
		angle+=18;
		scale=((GetEnemyX-GetX)^2+(GetEnemyY-GetY)^2)^0.5/150;
		if(GetArgument==0)
		{
			SetSpeed(((GetEnemyX-GetX)^2+(GetEnemyY-GetY)^2)^0.5/150*2+1);
		}
		if(GetArgument==1)
		{
			SetSpeed(((GetEnemyX-GetX)^2+(GetEnemyY-GetY)^2)^0.5/100*2+1);
		}
		if(GetY>GetClipMaxY+60||GetY<GetClipMinY-60||GetX>GetClipMaxX+60||GetX<GetClipMinX-60)
		{
			End;
		}

		yield;
	}
	@Finalize
	{
	}
	@DrawLoop
	{
		if(GetArgument==0)
		{
			SetRenderState(ADD);
		}
		SetTexture(GetCurrentScriptDirectory~".\img\shot\bullet.png");
		if(GetArgument==0)
		{
			SetGraphicRect(1,450,63,511);
		}
		if(GetArgument==1)
		{
			SetGraphicRect(67,167,77,184);
		}
		SetGraphicScale(scale,scale);
		if(GetArgument==0)
		{
			SetGraphicAngle(0,0,angle);
		}
		if(GetArgument==1)
		{
			SetGraphicAngle(0,0,GetAngle+90);
		}
		DrawGraphic(GetX,GetY);
	}
}